package com.ces.newPOS.admin.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;

/**
 *
 * @author ReutyCheng
 */
@MappedSuperclass
public class AuditableEntity implements Serializable
{
  private static final long serialVersionUID = 1L;
 
  @Temporal(javax.persistence.TemporalType.DATE)
  protected Date createdDate;
  protected String createdBy;

  @Temporal(javax.persistence.TemporalType.DATE)
  protected Date lastModifiedDate;
  protected String lastModifiedBy;
  @Version
  protected Integer optcount;

  public String getCreatedBy()
  {
    return createdBy;
  }

  public void setCreatedBy(String createdBy)
  {
    this.createdBy = createdBy;
  }

  public Date getCreatedDate()
  {
    return createdDate;
  }

  public void setCreatedDate(Date createdDate)
  {
    this.createdDate = createdDate;
  }

  public String getLastModifiedBy()
  {
    return lastModifiedBy;
  }

  public void setLastModifiedBy(String lastModifiedBy)
  {
    this.lastModifiedBy = lastModifiedBy;
  }

  public Date getLastModifiedDate()
  {
    return lastModifiedDate;
  }

  public void setLastModifiedDate(Date lastModifiedDate)
  {
    this.lastModifiedDate = lastModifiedDate;
  }

  public Integer getOptcount()
  {
    return optcount;
  }

  public void setOptcount(Integer optcount)
  {
    this.optcount = optcount;
  }

  public void prePersist()
  {
    if (this.getCreatedDate() == null)
    {
      this.setCreatedDate(new Date());
    }
    this.setLastModifiedDate(new Date());
  }

  public void preUpdate()
  {
    if (this.getCreatedDate() == null)
    {
      this.setCreatedDate(new Date());
    }
    this.setLastModifiedDate(new Date());
  }
}
